package com.eedi.framework.logger.controller.org;

import com.eedi.framework.common.enums.UserTypeEnum;
import com.eedi.framework.common.pojo.CommonResult;
import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.logger.controller.org.vo.OrgOperateLogPageReq;
import com.eedi.framework.logger.controller.org.vo.OrgOperateLogResp;
import com.eedi.framework.logger.service.OrgLogOperateService;
import com.eedi.framework.security.core.util.SecurityFrameworkUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.eedi.framework.common.pojo.CommonResult.success;


@Tag(name = "经营界面 - 机构操作日志")
@RestController
@RequestMapping("/org-operate-log")
@Validated
public class OrgOperateLogController {

    @Resource
    private OrgLogOperateService orgLogOperateService;

    @GetMapping("/page")
    @Operation(summary = "查看操作日志分页列表")
    @PreAuthorize("@org.hasPermission('org:operate-log:query')")
    public CommonResult<PageResult<OrgOperateLogResp>> pageOperateLog(OrgOperateLogPageReq pageReqVO) {
        pageReqVO.setUserType(UserTypeEnum.MEMBER_OPS);
        PageResult<OrgOperateLogResp> pageResult = orgLogOperateService.getOperateLogPage(pageReqVO, SecurityFrameworkUtils.getOrgInfoId());
        return success(pageResult);
    }

}
